document.addEventListener('DOMContentLoaded', function() {
    // 获取所有问答项
    const faqQuestions = document.querySelectorAll('.faq-question');
    
    // 为每个问答项添加点击事件
    faqQuestions.forEach(question => {
        question.addEventListener('click', function() {
            // 获取当前问答项的答案部分
            const answer = this.nextElementSibling;
            const icon = this.querySelector('.toggle-icon');
            
            // 切换答案的显示/隐藏
            answer.classList.toggle('active');
            
            // 切换图标
            if (answer.classList.contains('active')) {
                icon.textContent = '-';
            } else {
                icon.textContent = '+';
            }
            
            // 关闭其他打开的问答项
            faqQuestions.forEach(otherQuestion => {
                if (otherQuestion !== question) {
                    const otherAnswer = otherQuestion.nextElementSibling;
                    const otherIcon = otherQuestion.querySelector('.toggle-icon');
                    otherAnswer.classList.remove('active');
                    otherIcon.textContent = '+';
                }
            });
        });
    });
    
    // 默认展开第一个问答项
    if (faqQuestions.length > 0) {
        faqQuestions[0].click();
    }
});